import {defineStore} from 'pinia'
import * as userApi from '@/api/system/user'
import * as materialApi from '@/api/business/material'

export const useOptionStore = defineStore('selectOptions', () => {
  const userOption = ref([])

  async function getUseOption() {
    const {list} = await userApi.getUserPage({pageNo: 1, pageSize: 100})
    userOption.value = list.map(item => {
      return {
        label: item.nickname,
        value: item.id
      }
    })
  }

  getUseOption()


  const materialOption = ref([])

  async function getMaterialOption() {
    const {list} = await materialApi.getMaterialPage()
    materialOption.value = list.map(item => {
      return {
        label: item.productName,
        value: item.id
      }
    })
  }

  getMaterialOption()
  return {
    userOption, materialOption,
    getMaterialOption, getUseOption
  }
})
